(function () {
    return {
        initControl: function (oControl) {
            var v = oControl.value;
            v.datavar = 0;
            v.usetime=0;
        },
        compile: function (compileContext, doc, entity) {
            var cc = compileContext;
            var v = entity.value;
            var tc = cc.templateCoder;

            var dataName = cc.findDataName(doc,entity.value.datavar);


            if( dataName)
                cc.dataNames.push(dataName);
            
            var dateid = cc.newID();
            
            tc.add("<eui-page path=\"/ebfcontrol/form/date/index\" datas=\"usetime:" +
                (entity.value.usetime ? "1" : "0") +
                "\" params=\"" +
                (dataName ? "selday:" + dataName + ".value" : "") +
                "\" events=\"onChange:notifyDate" + dateid + "\"/>");

            cc.eventCoder.add("notifyDate" + dateid + ":function(dt,dtstr){" +
                (dataName?"this."+dataName+".value=dtstr;":"")+
                "}");


        }
    }
})();